﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Mod_ReportManage_frm_PrintReport : System.Web.UI.Page
{
    private void GetReportDataSet()
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            ClsReportDAL cls_report = new ClsReportDAL();

            DataSet dst = cls_report.GetReportInfo();

            this.dlstResult.DataSource = dst;
            this.dlstResult.DataBind();
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            if (!IsPostBack)
            {
                this.GetReportDataSet();
            }
            else
            {
                this.lblJs.Text = "";
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.lblJs.Text = "<script>parent.window.location.href='../index.aspx'</script>";
        }
    }

    protected void ibtnRef_Click(object sender, ImageClickEventArgs e)
    {

    }

    protected void OpenPrintWin(object sender, EventArgs e)
    {
        LinkButton lbtn = (LinkButton)sender;

        bool is_stop = bool.Parse(lbtn.CommandName.Trim());

        if (!is_stop)
        {
            string strReportUrl = lbtn.CommandArgument.Trim();
            short intType = lbtn.TabIndex;

            if (intType == 1)
            {
                this.lblJs.Text = "<script>ModalDialog('frm_SetReportParam.aspx?ReportUrl=" + strReportUrl + "', 350, 230);</script>";
            }
            else
            {
                this.lblJs.Text = "<script>var win = window.open('frm_PrintPage.aspx?ReportUrl=" + strReportUrl + "&Params=','','top=0, left=0, toolbar=no, menubar=no,scrollbars=no, resizable=yes,location=no, status=no');";
                this.lblJs.Text += "win.moveTo(0,0); win.resizeTo(screen.availWidth,screen.availHeight);</script>";
            }
        }
        else
        {
            this.lblJs.Text = "<script>alert('抱歉！该报表已停止使用，请与系统管理员联系。');</script>";
        }
    }

    protected void dlstResult_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemIndex != -1)
        {
            LinkButton lbtn = (LinkButton)e.Item.FindControl("lbtnPrint");

            string strName = lbtn.Text.Trim();

            if (strName.Length > 12)
            {
                lbtn.Text = strName.Substring(0, 12) + "...";
            }

            lbtn.TabIndex = short.Parse(((Label)e.Item.FindControl("lblType")).Text.Trim());
        }
    }
}
